@php use Illuminate\Support\Facades\Auth; @endphp
<nav class="navbar navbar-expand-lg bg-body-tertiary navbar-static-top shadow-sm">
    <div class="container">
        <a class="navbar-brand d-flex justify-content-start align-items-center" href="{{route('root')}}">
            <img src="{{url('pics/logo/laravel.jpg')}}" alt="logo"
                 class="rounded  d-inline-block align-text-top me-2"
                 width="30"/>
            Luntan2
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link
                     {{active_class(if_route('topics.index'))}}
                    " aria-current="page" href="{{route('topics.index')}}">首页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link
                        {{category_nav_active(1)}}
                    " href="{{route('categories.show',1)}}">新闻</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link
                      {{category_nav_active(2)}}
                    " href="{{route('categories.show',2)}}">体育</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link
                        {{category_nav_active(3)}}
                    " href="{{route('categories.show',3)}}">娱乐</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link
                        {{category_nav_active(4)}}
                    " href="{{route('categories.show',4)}}">旅行</a>
                </li>
            </ul>
            <ul class="navbar-nav navbar-right">
                @guest
                    <li class="nav-item">
                        <a class="nav-link" href="{{route('login')}}">
                            登录
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{route('register')}}">
                            注册
                        </a>
                    </li>
                @else
                    @can('manage_contents')
                    <li class="nav-item d-flex align-items-center">
                        <a class="text-success" href="{{url(config('administrator.uri'))}}" title="进入后台管理">
                            <i class="fa-solid fa-gauge"></i>
                        </a>
                    </li>
                    @endcan
                    <li class="nav-item d-flex align-items-center me-4">
                        <a href="{{route('notifications.index')}}" class="btn position-relative" title="消息通知">
                            <i class="fa-regular fa-bell"></i>
                            <span
                                class="position-absolute top-0 start-100 translate-middle badge rounded-pill
                                 bg-{{Auth::user()->notification_count > 0 ? 'danger' : 'secondary'}}">
                            {{Auth::user()->notification_count}}
                            <span class="visually-hidden">unread messages</span>
                          </span>
                        </a>
                    </li>
                    <li class="nav-item d-flex align-items-center">
                        <a href="{{route('topics.create')}}" title="创建帖子">
                            <i class="fa-solid fa-circle-plus "></i>
                        </a>
                    </li>

                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
                           aria-expanded="false">
                            <img src="{{Auth::user()->avatar}}" alt="Jack" class="img-thumbnail" width="40">
                            {{Auth::user()->name}}
                        </a>
                        <ul class="dropdown-menu text-center">
                            <li><a class="dropdown-item" href="{{route('users.show',Auth::id())}}">
                                    <i class="fa-regular fa-user "></i>
                                    个人中心
                                </a>
                            </li>
                            <li><a class="dropdown-item" href="{{route('users.edit',Auth::id())}}">
                                    <i class="fa-solid fa-pen-nib "></i>
                                    编辑资料
                                </a></li>
                            <li>
                                <hr class="dropdown-divider">
                            </li>
                            <li><a class="dropdown-item" href="#">
                                    <form action="{{route('logout')}}" method="POST"
                                          onclick="return confirm('您确认要退出吗?')"
                                    >
                                        @csrf
                                        <button type="submit" class="btn btn-sm btn-danger">退出</button>
                                    </form>
                                </a></li>
                        </ul>
                    </li>
                @endguest
            </ul>
        </div>
    </div>
</nav>
